<template>
    <div style=" position: relative;"><el-card>
            <template #header>
                <!-- 搜索 -->
                <div class="checkPointIds_change_scc">
                    <el-select filterable v-if='role_off' popper-class="xiala_css" @change="checkPointIds_change"
                        collapse-tags collapse-tags-tooltip multiple clearable v-model="checkPointIds"
                        placeholder="请选择客户" style="width: 260px">
                        <template #header>
                            <el-checkbox v-model="checkAll" :indeterminate="indeterminate" @change="handleCheckAll">
                                全选
                            </el-checkbox>
                        </template>
                        <el-option v-for="item in getCustomerList_list" :key="item.id" :label="item.customerName"
                            :value="item.id" />
                    </el-select>
                    <el-select filterable popper-class="xiala_css" @change="getPipeLineListByCusId_change" collapse-tags
                        collapse-tags-tooltip multiple clearable v-model="getPipeLineListByCusId_value"
                        placeholder="请选择管线" style="width: 260px;margin-left:15px;">
                        <template #header>
                            <el-checkbox v-model="checkAll2" :indeterminate="indeterminate2" @change="handleCheckAll2">
                                全选
                            </el-checkbox>
                        </template>
                        <el-option v-for="item in getPipeLineListByCusId_list" :key="item.id" :label="item.pipeLineName"
                            :value="item.id" />
                    </el-select>
                    <el-select filterable popper-class="xiala_css" collapse-tags collapse-tags-tooltip multiple
                        clearable v-model="getCheckPointListByLineId_value" placeholder="请选择监测点"
                        style="width: 260px;margin-left:15px;">
                        <template #header>
                            <el-checkbox v-model="checkAll3" :indeterminate="indeterminate3" @change="handleCheckAll3">
                                全选
                            </el-checkbox>
                        </template>
                        <el-option v-for="item in getCheckPointListByLineId_list" :key="item.id"
                            :label="item.checkPointName" :value="item.id" />
                    </el-select>



                    <el-date-picker popper-class="time_css" style="width: 340px;margin-left:15px;"
                        :default-time="defaultTime" v-model="details_time" type="datetimerange"
                        start-placeholder="选择开始时间" end-placeholder="选择结束时间" format="YYYY-MM-DD HH:mm:ss"
                        value-format="YYYY-MM-DD HH:mm:ss" />
                    <el-button style="margin-left: 20px;height:30px" @click="search_btn" type="primary"
                        icon="Search">搜索</el-button>
                </div>
                <!-- 功能按钮 -->
                <!-- <div class="del_btn_Css">

                    <el-button @click="del_btn" type="danger" icon="DeleteFilled">删除</el-button>
                    <el-button @click="out_btn" type="warning" icon="Promotion">导出</el-button>
                </div> -->
            </template>
            <div>
                <el-tabs type="card" v-model="activeName" class="demo-tabs" @tab-click="handleClick">
                    <el-tab-pane style="overflow: auto;" label="基础数据" name="基础数据">
                        <div style="width:80vw;height:600px;">
                            <div v-if="getKmlcpycList_off" ref="chart_container2" style="width: 80vw; height: 600px;">
                            </div>
                            <div v-else style="width: 100%; height: 600px;font-size:20px;font-weight:700;text-align: center;
                            line-height: 350px;color: #686822;">
                                请先选择客户、管线、监测点
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER电流" name="ER电流">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container3" style="width: 80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER电压" name="ER电压">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container4" style="width: 80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER电流密度" name="ER电流密度">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container5" style="width: 80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER电阻" name="ER电阻">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container6" style="width: 80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER极化电位" name="ER极化电位">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container7" style="width: 80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER试片" name="ER试片">
                        <div style="width:80vw;height:600px;">
                            <div ref="chart_container8" style="width:80vw; height: 600px;"></div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane style="overflow: auto;" label="ER腐蚀率" name="ER腐蚀率">
                        <div style="width:80vw;height:600px;">
                            <div style="width:80vw;height:600px;overflow: auto;">
                                <div ref="chart_container9" style="width:80vw; height: 600px;"></div>
                            </div>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </div>
        </el-card>

        <!-- 弹窗 -->
        <div>
           
            <!-- 表格筛选 -->
            <div v-if="wid == 0" style="position: absolute;top:100px;z-index: 2;"
                :style="icon_off ? 'right:590px;' : 'right:700px;'">
                <el-icon @click="icon_btn" :size="20">
                    <Setting />
                </el-icon>
                <div v-show="icon_off" style=" position: relative;top:-100px;left:50px;width: 130px;height:430px;background:#fff;overflow: hidden;border: 1px solid #f89898;
    border-radius: 5px;">
                    <div class="cols-set" style="background:#fff;width:90%;height:97%;margin:auto;margin-top:10px;">
                        <div>
                            <el-button-group style="display: flex;justify-content: center; ">
                                <el-tooltip effect="dark" placement="bottom">
                                    <template #content>注意：取消选项会隐藏可视图的项目，<br />记得点击保存才会生效哦！ </template>
                                    <el-button style="width:10px" type="primary" icon="WarningFilled"></el-button>
                                </el-tooltip>
                                <!-- <el-button title="重置" type="primary" icon="Refresh" @click="resetTableSet"></el-button> -->
                                <el-button title="保存" type="primary" @click="saveTableSet">保存</el-button>
                            </el-button-group>
                            <div class="col-items" style="height:400px; overflow-y: auto; ">
                                <el-checkbox @change="checkbox_btn" v-for="item in table_data_list_new"
                                    :key="item.label" v-model="item.off" :label="item.label" border>
                                </el-checkbox>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

            <!-- 表格筛选 -->
            <div v-if="wid == 1" style="position: absolute;top:100px;z-index: 2;"
                :style="icon_off ? 'right:0px;' : 'right:100px;'">
                <el-icon @click="icon_btn" :size="20">
                    <Setting />
                </el-icon>
                <div v-show="icon_off" style=" position: relative;top:-100px;left:50px;width: 130px;height:430px;background:#fff;overflow: hidden;border: 1px solid #f89898;
    border-radius: 5px;">
                    <div class="cols-set" style="background:#fff;width:90%;height:97%;margin:auto;margin-top:10px;">
                        <div>
                            <el-button-group style="display: flex;justify-content: center; ">
                                <el-tooltip effect="dark" placement="bottom">
                                    <template #content>注意：取消选项会隐藏可视图的项目，<br />记得点击保存才会生效哦！ </template>
                                    <el-button style="width:10px" type="primary" icon="WarningFilled"></el-button>
                                </el-tooltip>
                                <!-- <el-button title="重置" type="primary" icon="Refresh" @click="resetTableSet"></el-button> -->
                                <el-button title="保存" type="primary" @click="saveTableSet">保存</el-button>
                            </el-button-group>
                            <div class="col-items" style="height:400px; overflow-y: auto; ">
                                <el-checkbox @change="checkbox_btn" v-for="item in table_data_list_new"
                                    :key="item.label" v-model="item.off" :label="item.label" border>
                                </el-checkbox>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import * as echarts from 'echarts'
import { ref, reactive, onMounted, computed, watch, nextTick, markRaw } from 'vue'
import {
    getCustomerList, getPipeLineListByCusId, getCheckPointListByLineId, getKmlcpycList,
} from '@/api/statistic_analysis.js'
import { ElMessage, ElLoading, ElMessageBox } from 'element-plus'
import { downFiles, } from '@/utils/common.js'
import CircularJSON from 'circular-json'
onMounted(async () => {
    let screenWidth1 = window.innerWidth;
    if (screenWidth1 > 1800) {
        wid.value = 0
    } else {
        wid.value = 1
    }
    let test_pile_data_analysis = JSON.parse(localStorage.getItem('test_pile_data_analysis'))
    if (test_pile_data_analysis) {

        nuv_off.value = true
        await getCustomerList_api()
        await role_api()
    } else {
        await getCustomerList_api()
        await role_api()
    }


    if (activeName.value == '基础数据') {
        let ceshi_jichu = JSON.parse(localStorage.getItem('ceshi_jichu'))
        ceshi_jichu ? table_data_list_new.value = ceshi_jichu : table_data_list_new.value = table_data_list1

    } else if (activeName.value == 'ER电流') {
        let ceshi_2 = JSON.parse(localStorage.getItem('ceshi_2'))
        ceshi_2 ? table_data_list_new.value = ceshi_2 : table_data_list_new.value = table_data_list2
    } else if (activeName.value == 'ER电压') {
        let ceshi_3 = JSON.parse(localStorage.getItem('ceshi_3'))
        ceshi_3 ? table_data_list_new.value = ceshi_3 : table_data_list_new.value = table_data_list3
    } else if (activeName.value == 'ER电流密度') {
        let ceshi_4 = JSON.parse(localStorage.getItem('ceshi_4'))
        ceshi_4 ? table_data_list_new.value = ceshi_4 : table_data_list_new.value = table_data_list4
    } else if (activeName.value == 'ER电阻') {
        let ceshi_5 = JSON.parse(localStorage.getItem('ceshi_5'))
        ceshi_5 ? table_data_list_new.value = ceshi_5 : table_data_list_new.value = table_data_list5
    } else if (activeName.value == 'ER极化电位') {
        let ceshi_6 = JSON.parse(localStorage.getItem('ceshi_6'))
        ceshi_6 ? table_data_list_new.value = ceshi_6 : table_data_list_new.value = table_data_list6
    } else if (activeName.value == 'ER试片') {
        let ceshi_7 = JSON.parse(localStorage.getItem('ceshi_7'))
        ceshi_7 ? table_data_list_new.value = ceshi_7 : table_data_list_new.value = table_data_list7
    } else if (activeName.value == 'ER腐蚀率') {
        let ceshi_8 = JSON.parse(localStorage.getItem('ceshi_8'))
        ceshi_8 ? table_data_list_new.value = ceshi_8 : table_data_list_new.value = table_data_list8
    }

})
const wid = ref(0)

//#region 表格数据处理
const table_data_list_new = ref([])
const table_data_list1 = reactive([
    { label: '电池电压', off: true },
    { label: '通电电位', off: true },
    { label: '断电电位', off: true },
    { label: '交流杂散电压', off: true },
    { label: '自然电位', off: true },
    { label: 'ER腐蚀仪电池电压', off: true },
    { label: '牺牲阳极开路电位', off: true },
])
const table_data_list2 = reactive([
    { label: 'ER探头1直流电流', off: true },
    { label: 'ER探头2直流电流', off: true },
    { label: 'ER探头1交流杂散电流', off: true },
    { label: 'ER探头2交流杂散电流', off: true },
])
const table_data_list3 = reactive([
    { label: 'ER探头1交流杂散电', off: true },
    { label: 'ER探头2交流杂散电压', off: true },
])
const table_data_list4 = reactive([
    { label: 'ER探头1直流电流密度', off: true },
    { label: 'ER探头2直流电流密度', off: true },
    { label: 'ER探头1交流杂散电流密度', off: true },
    { label: 'ER探头2交流杂散电流密度', off: true },
])
const table_data_list5 = reactive([
    { label: 'ER探头1电阻', off: true },
    { label: 'ER探头2电阻', off: true },
])
const table_data_list6 = reactive([
    { label: 'ER探头1极化电位', off: true },
    { label: 'ER探头2极化电位', off: true },
])
const table_data_list7 = reactive([
    { label: 'ER试片1厚度', off: true },
    { label: 'ER试片2厚度', off: true },
])
const table_data_list8 = reactive([
    { label: 'ER探头1腐蚀率', off: true },
    { label: 'ER探头2腐蚀率', off: true },
])
const resetTableSet = () => {

    if (activeName.value == '基础数据') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list1))
        localStorage.setItem('ceshi_jichu', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电流') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list2))
        localStorage.setItem('ceshi_2', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电压') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list3))
        localStorage.setItem('ceshi_3', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电流密度') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list4))
        localStorage.setItem('ceshi_4', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电阻') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list5))
        localStorage.setItem('ceshi_5', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER极化电位') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list6))
        localStorage.setItem('ceshi_6', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER试片') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list7))
        localStorage.setItem('ceshi_7', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER腐蚀率') {
        table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list8))
        localStorage.setItem('ceshi_8', CircularJSON.stringify(table_data_list_new.value))
    }

    icon_off.value = false
    search_btn()
}
const saveTableSet = () => {
    if (activeName.value == '基础数据') {
        localStorage.setItem('ceshi_jichu', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电流') {
        localStorage.setItem('ceshi_2', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电压') {
        localStorage.setItem('ceshi_3', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电流密度') {
        localStorage.setItem('ceshi_4', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER电阻') {
        localStorage.setItem('ceshi_5', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER极化电位') {
        localStorage.setItem('ceshi_6', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER试片') {
        localStorage.setItem('ceshi_7', CircularJSON.stringify(table_data_list_new.value))
    } else if (activeName.value == 'ER腐蚀率') {
        localStorage.setItem('ceshi_8', CircularJSON.stringify(table_data_list_new.value))
    }



    icon_off.value = false
    search_btn()
}



const icon_off = ref(false)
const icon_btn = () => {
    icon_off.value = !icon_off.value

}


const checkbox_btn = (e, c) => {
    for (let i = 0; i < table_data_list_new.value.length; i++) {
        if (table_data_list_new.value[i].label == c.target._value) {
            table_data_list_new.value[i].off == e

        }

    }

}


//#endregion



let nuv_off = ref(false)
//#region 登录角色判断 
//  
let role_off = ref(true)
let role_id = ref('')
let role_customerId = ref('')
const role_api = () => {
    let luser = JSON.parse(localStorage.getItem('luser'))
    if (luser.loginName != 'admin') {
        role_off.value = false
        role_id.value = luser.id
        role_customerId.value = luser.customerId
        checkPointIds.value = []
        checkPointIds.value.push(role_customerId.value)
        getCustomerList_list.value = []
        getCustomerList_list.value.push(role_customerId.value)
    }
}
// #endregion

const data_list = ref([''])



//#region 搜索
//#region 客户
const getKmlcpycList_off = ref(false)
const getCustomerList_list = ref([])
const checkPointIds = ref([])
const checkAll = ref(false)
const indeterminate = ref(false)
watch(checkPointIds, (val) => {
    getPipeLineListByCusId_value.value = []
    getCheckPointListByLineId_value.value = []
    if (val.length === 0) {
        checkAll.value = false
        indeterminate.value = false
    } else if (val.length === getCustomerList_list.value.length) {
        checkAll.value = true
        indeterminate.value = false
    } else {
        indeterminate.value = true
    }
})
const handleCheckAll = async (val) => {
    getPipeLineListByCusId_value.value = []
    getCheckPointListByLineId_value.value = []
    indeterminate.value = false
    if (val) {
        checkPointIds.value = getCustomerList_list.value.map((_) => _.id)

    } else {
        checkPointIds.value = []
    }
    getCustomerList_api()
}
const checkPointIds_change = async (e) => {
    getPipeLineListByCusId_api()
}


const getCustomerList_api = () => {

    getPipeLineListByCusId_value.value = []
    getCheckPointListByLineId_value.value = []
    getCustomerList({}).then(res => {
        if (res.resultStatus.resultCode == '0000') {
            getCustomerList_list.value = res.value
            if (nuv_off.value) {
                console.log(1)
                let test_pile_data_analysis = JSON.parse(localStorage.getItem('test_pile_data_analysis'))
                checkPointIds.value = test_pile_data_analysis.customerIds
            }
            getPipeLineListByCusId_api()

        } else {
            return ElMessage({
                message: res.resultStatus.resultMessage,
                type: 'warning',
            })
        }

    })
}


//#endregion

//#region 管线
const getPipeLineListByCusId_list = ref([])
const getPipeLineListByCusId_value = ref([])
const checkAll2 = ref(false)
const indeterminate2 = ref(false)
watch(getPipeLineListByCusId_value, (val) => {
    getCheckPointListByLineId_value.value = []
    if (val.length === 0) {
        checkAll2.value = false
        indeterminate2.value = false
    } else if (val.length === getPipeLineListByCusId_list.value.length) {
        checkAll2.value = true
        indeterminate2.value = false
    } else {
        indeterminate2.value = true
    }
})
const handleCheckAll2 = (val) => {
    getCheckPointListByLineId_value.value = []
    indeterminate2.value = false
    if (val) {
        getPipeLineListByCusId_value.value = getPipeLineListByCusId_list.value.map((_) => _.id)

    } else {
        getPipeLineListByCusId_value.value = []
    }
    getCheckPointListByLineId_api()
}
const getPipeLineListByCusId_change = async (e) => {
    await getCheckPointListByLineId_api()
}

const getPipeLineListByCusId_api = () => {


    getCheckPointListByLineId_value.value = []

    getPipeLineListByCusId(checkPointIds.value.length > 0 ? checkPointIds.value : data_list.value).then(res => {
        if (res.resultStatus.resultCode == '0000') {
            getPipeLineListByCusId_list.value = res.value

            if (nuv_off.value) {

                let test_pile_data_analysis = JSON.parse(localStorage.getItem('test_pile_data_analysis'))
                getPipeLineListByCusId_value.value = test_pile_data_analysis.pipeLineIds


            }


            getCheckPointListByLineId_api()

        } else {
            return ElMessage({
                message: res.resultStatus.resultMessage,
                type: 'warning',
            })
        }

    })
}
//#endregion

//#region 监测点
const getCheckPointListByLineId_value = ref([])
const getCheckPointListByLineId_list = ref([])
const checkAll3 = ref(false)
const indeterminate3 = ref(false)
watch(getCheckPointListByLineId_value, (val) => {
    if (val.length === 0) {
        checkAll3.value = false
        indeterminate3.value = false
    } else if (val.length === getCheckPointListByLineId_list.value.length) {
        checkAll3.value = true
        indeterminate3.value = false
    } else {
        indeterminate3.value = true
    }
})
const handleCheckAll3 = (val) => {
    indeterminate3.value = false
    if (val) {
        getCheckPointListByLineId_value.value = getCheckPointListByLineId_list.value.map((_) => _.id)

    } else {
        getCheckPointListByLineId_value.value = []
    }
}
const getCheckPointListByLineId_api = () => {
    let ps = {
        deviceType: '1',
        ids: getPipeLineListByCusId_value.value.length > 0 ? getPipeLineListByCusId_value.value : data_list.value
    }



    getCheckPointListByLineId(ps).then(res => {

        if (res.resultStatus.resultCode == '0000') {
            getCheckPointListByLineId_list.value = res.value

            if (nuv_off.value) {
                let test_pile_data_analysis = JSON.parse(localStorage.getItem('test_pile_data_analysis'))
                getCheckPointListByLineId_value.value = test_pile_data_analysis.checkPointIds
                details_time.value[1] = test_pile_data_analysis.endTime

                details_time.value[0] = test_pile_data_analysis.startTime
                details_time.value = [test_pile_data_analysis.startTime, test_pile_data_analysis.endTime]



                getKmlcpycList_api()
                nuv_off.value = false
            }




        } else {
            return ElMessage({
                message: res.resultStatus.resultMessage,
                type: 'warning',
            })
        }

    })
}
//#endregion

//#region 时间
// 获取今天的年月日
const getCurrentDateTime = () => {
    let currentDate = new Date();

    // 获取当前日期的时间戳（以毫秒为单位）
    let timestamp = currentDate.getTime();

    // 计算昨天的时间戳
    let yesterdayTimestamp = timestamp - (24 * 60 * 60 * 1000);

    // 使用昨天的时间戳创建日期对象
    let yesterdayDate = new Date(yesterdayTimestamp);

    // 从昨天的日期对象中提取年、月、日、小时、分钟和秒
    let year = yesterdayDate.getFullYear();
    let month = String(yesterdayDate.getMonth() + 1).padStart(2, '0');
    let day = String(yesterdayDate.getDate()).padStart(2, '0');

    // 构建格式为 "YYYY-MM-DD HH:mm:ss" 的昨天时间字符串
    let yesterdayTime = `${year}-${month}-${day}`;
    return yesterdayTime;
}
const getCurrentDateTime2 = () => {
    let now = new Date();

    let year = now.getFullYear().toString().padStart(4, '0');
    let month = (now.getMonth() + 1).toString().padStart(2, '0');
    let day = now.getDate().toString().padStart(2, '0');
    let hours = now.getHours().toString().padStart(2, '0');
    let minutes = now.getMinutes().toString().padStart(2, '0');
    let seconds = now.getSeconds().toString().padStart(2, '0');

    let dateTimeString = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    return dateTimeString;
}

const time1 = ref(getCurrentDateTime() + ' ' + '00:00:00')
const time2 = ref(getCurrentDateTime2())
const defaultTime = [
    new Date(2000, 1, 1, 0, 0, 0),
    new Date(2000, 2, 1, 23, 59, 59),
]
const details_time = ref([time1.value, time2.value])
//#endregion
//#region 异常统计图弹出

const chart = ref('')


//#endregion
const search_btn = () => {
    if (checkPointIds.value.length <= 0) {
        return ElMessage({
            message: '请选择客户！',
            type: 'warning',
        })
    } else if (getPipeLineListByCusId_value.value.length <= 0) {
        console.log(1, getPipeLineListByCusId_value.value)
        return ElMessage({
            message: '请选择管线！',
            type: 'warning',
        })
    } else if (getCheckPointListByLineId_value.value.length <= 0) {
        console.log(2, getCheckPointListByLineId_value.value)
        return ElMessage({
            message: '请选择监测点！',
            type: 'warning',
        })
    } else if (!details_time.value) {
        return ElMessage({
            message: '请选择时间！',
            type: 'warning',
        })
    }
    getKmlcpycList_api()

}
const getKmlcpycList_list = ref([])
const getKmlcpycList_api = () => {
    const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        background: 'rgba(0, 0, 0, 0.7)',
    })
    let ps = {
        checkPointIds: getCheckPointListByLineId_value.value,
        customerIds: checkPointIds.value,
        pipeLineIds: getPipeLineListByCusId_value.value,
        startTime: details_time.value[0],
        endTime: details_time.value[1],


    }
    // localStorage.setItem('test_pile_data_analysis', CircularJSON.stringify(ps))
    getKmlcpycList(ps).then(res => {
        if (res.resultStatus.resultCode == '0000') {
            getKmlcpycList_list.value = res.value
            getKmlcpycList_off.value = true
            if (activeName.value == '基础数据') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                basic_data()
            } else if (activeName.value == 'ER电流') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_current()
            } else if (activeName.value == 'ER电压') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_voltage()
            } else if (activeName.value == 'ER电流密度') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_current_density()
            } else if (activeName.value == 'ER电阻') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_resistance()
            } else if (activeName.value == 'ER极化电位') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_polarization_potential()
            } else if (activeName.value == 'ER试片') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_test_piece()
            } else if (activeName.value == 'ER腐蚀率') {
                if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
                    chart.value.dispose();
                }
                ER_corrosion_rate()
            }

        } else {
            return ElMessage({
                message: res.resultStatus.resultMessage,
                type: 'warning',
            })
        }
        loading.close()
    })
    let tier = null
    clearTimeout(tier)
    tier = setTimeout(() => {
        loading.close()
    }, 5000)
}
const activeName = ref('基础数据')
const chart_container2 = ref('')
const handleClick = (tab, event) => {

    if (chart.value._componentsViews && chart.value._componentsViews.length > 0) {
        chart.value.dispose();
    }
    if (tab.props.name == '基础数据') {
        let ceshi_jichu = JSON.parse(localStorage.getItem('ceshi_jichu'))
        ceshi_jichu ? table_data_list_new.value = ceshi_jichu : table_data_list_new.value = table_data_list1
        basic_data()
    } else if (tab.props.name == 'ER电流') {
        let ceshi_2 = JSON.parse(localStorage.getItem('ceshi_2'))
        ceshi_2 ? table_data_list_new.value = ceshi_2 : table_data_list_new.value = table_data_list2
        ER_current()
    } else if (tab.props.name == 'ER电压') {
        let ceshi_3 = JSON.parse(localStorage.getItem('ceshi_3'))
        ceshi_3 ? table_data_list_new.value = ceshi_3 : table_data_list_new.value = table_data_list3
        ER_voltage()
    } else if (tab.props.name == 'ER电流密度') {
        let ceshi_4 = JSON.parse(localStorage.getItem('ceshi_4'))
        ceshi_4 ? table_data_list_new.value = ceshi_4 : table_data_list_new.value = table_data_list4
        ER_current_density()
    } else if (tab.props.name == 'ER电阻') {
        let ceshi_5 = JSON.parse(localStorage.getItem('ceshi_5'))
        ceshi_5 ? table_data_list_new.value = ceshi_5 : table_data_list_new.value = table_data_list5
        ER_resistance()
    } else if (tab.props.name == 'ER极化电位') {
        let ceshi_6 = JSON.parse(localStorage.getItem('ceshi_6'))
        ceshi_6 ? table_data_list_new.value = ceshi_6 : table_data_list_new.value = table_data_list6
        ER_polarization_potential()
    } else if (tab.props.name == 'ER试片') {
        let ceshi_7 = JSON.parse(localStorage.getItem('ceshi_7'))
        ceshi_7 ? table_data_list_new.value = ceshi_7 : table_data_list_new.value = table_data_list7
        ER_test_piece()
    } else if (tab.props.name == 'ER腐蚀率') {
        let ceshi_8 = JSON.parse(localStorage.getItem('ceshi_8'))
        ceshi_8 ? table_data_list_new.value = ceshi_8 : table_data_list_new.value = table_data_list8
        ER_corrosion_rate()
    }
}
// 基础数据
const basic_data = () => {
    nextTick(() => {
        let sampTimeArr = []
        let batVoltageArr = []
        let onPotentialArr = []
        let offPotentialArr = []
        let acPotentialArr = []
        let selfPotentialArr = []
        let erCorBatVolArr = []
        let gradedPotentialArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                batVoltageArr.push(getKmlcpycList_list.value[i].batVoltage)
                onPotentialArr.push(getKmlcpycList_list.value[i].onPotential)
                offPotentialArr.push(getKmlcpycList_list.value[i].offPotential)
                acPotentialArr.push(getKmlcpycList_list.value[i].acPotential)
                selfPotentialArr.push(getKmlcpycList_list.value[i].selfPotential)
                erCorBatVolArr.push(getKmlcpycList_list.value[i].erCorBatVol)
                gradedPotentialArr.push(getKmlcpycList_list.value[i].gradedPotential)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }



        chart.value = markRaw(echarts.init(chart_container2.value));
        let data = ["电池电压", "通电电位", "断电电位", "交流杂散电压", "自然电位", "ER腐蚀仪电池电压", "牺牲阳极开路电位"]
        let series = [{
            name: "电池电压",
            type: 'line',
            stack: 'Total',
            data: batVoltageArr,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: '通电电位',
            type: 'line',
            data: onPotentialArr,
            connectNulls: true,//添加此属性
            symbolSize: 2,
            showSymbol: false,
            itemStyle: {
                normal: {
                    color: 'red',  //圈圈的颜色
                    lineStyle: {
                        color: 'red'  //线的颜色
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: '断电电位',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            type: 'line',
            data: offPotentialArr,
            itemStyle: {
                normal: {
                    color: '#38D621',
                    lineStyle: {
                        color: '#38D621'
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: '交流杂散电压',
            type: 'line',
            data: acPotentialArr,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            itemStyle: {
                normal: {
                    color: '#A4850A',
                    lineStyle: {
                        color: '#A4850A'
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: '自然电位',
            type: 'line',
            data: selfPotentialArr,
            connectNulls: true,//添加此属性
            symbolSize: 2,
            showSymbol: false,
            itemStyle: {
                normal: {
                    color: '#616161',
                    lineStyle: {
                        color: '#616161'
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: 'ER腐蚀仪电池电压',
            type: 'line',
            data: erCorBatVolArr,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            itemStyle: {
                normal: {
                    color: '#0270BC',
                    lineStyle: {
                        color: '#0270BC'
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }, {
            name: '牺牲阳极开路电位',
            type: 'line',
            data: gradedPotentialArr,
            connectNulls: true,//添加此属性
            symbolSize: 2,
            showSymbol: false,
            itemStyle: {
                normal: {
                    color: '#1E1E1E',
                    lineStyle: {
                        color: '#1E1E1E'
                    }
                }
            },
            markLine: {
                data: [
                    { yAxis: -0.85, name: '' },
                    { yAxis: -1.2, name: '' },
                    { yAxis: 4, name: '' }
                ]
            }
        }]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                show: true,
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                    // fontWeight:600
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    show: true,
                    interval: xIetm,
                    rotate: 45,
                    showMinLabel: true,
                    showMaxLabel: true,
                    textStyle: {
                        fontWeight: 600
                    }

                },
                // axisTick: {length:5},
            },
            series: series,
        };
        chart.value.setOption(option);
    })
}
// ER电流
const chart_container3 = ref('')
const ER_current = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erDirectCurrentAArr = []
        let erDirectCurrentBArr = []
        let erExchangeCurrentAArr = []
        let erExchangeCurrentBArr = []
        let anodeCurrent = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erDirectCurrentAArr.push(getKmlcpycList_list.value[i].erDirectCurrentA)
                erDirectCurrentBArr.push(getKmlcpycList_list.value[i].erDirectCurrentB)
                erExchangeCurrentAArr.push(getKmlcpycList_list.value[i].erExchangeCurrentA)
                erExchangeCurrentBArr.push(getKmlcpycList_list.value[i].erExchangeCurrentB)
                anodeCurrent.push(getKmlcpycList_list.value[i].anodeCurrent)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container3.value));
        let data = ["ER探头1直流电流", "ER探头2直流电流", "ER探头1交流杂散电流", "ER探头2交流杂散电流", "牺牲阳极输出电流"]
        let series = [{
            name: 'ER探头1直流电流',
            type: 'line',
            data: erDirectCurrentAArr,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            itemStyle: {
                normal: {
                    color: 'blue',
                    lineStyle: {
                        color: 'blue'
                    }
                }
            }
        }, {
            name: 'ER探头2直流电流',
            type: 'line',
            data: erDirectCurrentBArr,
            connectNulls: true,//添加此属性
            symbolSize: 2,
            showSymbol: false,
            itemStyle: {
                normal: {
                    color: 'red',
                    lineStyle: {
                        color: 'red'
                    }
                }
            }
        }, {
            name: 'ER探头1交流杂散电流',
            type: 'line',
            data: erExchangeCurrentAArr,
            symbolSize: 2,
            showSymbol: false,

            connectNulls: true,//添加此属性
            itemStyle: {
                normal: {
                    color: '#616161',
                    lineStyle: {
                        color: '#616161'
                    }
                }
            }
        }, {
            name: 'ER探头2交流杂散电流',
            type: 'line',
            data: erExchangeCurrentBArr,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            itemStyle: {
                normal: {
                    color: '#D5A90F',
                    lineStyle: {
                        color: '#D5A90F'
                    }
                }
            }
        }, {
            name: '牺牲阳极输出电流',
            type: 'line',
            data: anodeCurrent,
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            // itemStyle: {
            //     normal: {
            //         color: '#D5A90F',
            //         lineStyle: {
            //             color: '#D5A90F'
            //         }
            //     }
            // }
        }]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
// ER电压
const chart_container4 = ref('')
const ER_voltage = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erExchangeVoltageAArr = []
        let erExchangeVoltageBArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erExchangeVoltageAArr.push(getKmlcpycList_list.value[i].erExchangeVoltageA)
                erExchangeVoltageBArr.push(getKmlcpycList_list.value[i].erExchangeVoltageB)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container4.value));
        let series = [{
            name: 'ER探头1交流杂散电压',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erExchangeVoltageAArr,
        }, {
            name: 'ER探头2交流杂散电压',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erExchangeVoltageBArr,
        }]
        let data = ["ER探头1交流杂散电压", "ER探头2交流杂散电压"]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
// ER电流密度
const chart_container5 = ref('')
const ER_current_density = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erExchangeCurrentADensityArr = []
        let erExchangeCurrentBDensityArr = []
        let erDirectCurrentADensityArr = []
        let erDirectCurrentBDensityArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erExchangeCurrentADensityArr.push(getKmlcpycList_list.value[i].erExchangeCurrentADensity)
                erExchangeCurrentBDensityArr.push(getKmlcpycList_list.value[i].erExchangeCurrentBDensity)
                erDirectCurrentADensityArr.push(getKmlcpycList_list.value[i].erDirectCurrentADensity)
                erDirectCurrentBDensityArr.push(getKmlcpycList_list.value[i].erDirectCurrentBDensity)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container5.value));
        let series = [{
            name: 'ER探头1交流杂散电流密度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erExchangeCurrentADensityArr,
        }, {
            name: 'ER探头2交流杂散电流密度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erExchangeCurrentBDensityArr,
        }, {
            name: 'ER探头1直流电流密度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erDirectCurrentADensityArr,
        }, {
            name: 'ER探头2直流电流密度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erDirectCurrentBDensityArr,

        }]
        let data = ["ER探头1直流电流密度", "ER探头2直流电流密度", "ER探头1交流杂散电流密度", "ER探头2交流杂散电流密度",]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
//ER电阻
const chart_container6 = ref('')
const ER_resistance = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erProbeResistanceAArr = []
        let erProbeResistanceBArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erProbeResistanceAArr.push(getKmlcpycList_list.value[i].erProbeResistanceA)
                erProbeResistanceBArr.push(getKmlcpycList_list.value[i].erProbeResistanceB)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container6.value));
        let series = [{
            name: 'ER探头1电阻',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erProbeResistanceAArr,
        }, {
            name: 'ER探头2电阻',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erProbeResistanceBArr,
        }]
        let data = ["ER探头1电阻", "ER探头2电阻"]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
// ER极化电位
const chart_container7 = ref('')
const ER_polarization_potential = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erTestPieceOutageAArr = []
        let erTestPieceOutageBArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erTestPieceOutageAArr.push(getKmlcpycList_list.value[i].erTestPieceOutageA)
                erTestPieceOutageBArr.push(getKmlcpycList_list.value[i].erTestPieceOutageB)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container7.value));
        let series = [{
            name: 'ER探头1极化电位',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erTestPieceOutageAArr,
        }, {
            name: 'ER探头2极化电位',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erTestPieceOutageBArr,
        }]
        let data = ["ER探头1极化电位", "ER探头2极化电位"]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
// ER试片
const chart_container8 = ref('')
const ER_test_piece = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erTestPieceThickAArr = []
        let erTestPieceThickBArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erTestPieceThickAArr.push(getKmlcpycList_list.value[i].erTestPieceThickA)
                erTestPieceThickBArr.push(getKmlcpycList_list.value[i].erTestPieceThickB)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container8.value));
        let series = [{
            name: 'ER试片1厚度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erTestPieceThickAArr,
        }, {
            name: 'ER试片2厚度',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erTestPieceThickBArr,
        }]
        let data = ["ER试片1厚度", "ER试片2厚度"]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],
            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
// ER腐蚀率
const chart_container9 = ref('')
const ER_corrosion_rate = () => {
    nextTick(() => {
        let sampTimeArr = []
        let erProbeResistanceCorRateAArr = []
        let erProbeResistanceCorRateBArr = []
        let xIetm = ''
        if (getKmlcpycList_list.value.length > 0) {
            for (let i in getKmlcpycList_list.value) {
                sampTimeArr.push(getKmlcpycList_list.value[i].sampTime)
                erProbeResistanceCorRateAArr.push(getKmlcpycList_list.value[i].erProbeResistanceCorRateA)
                erProbeResistanceCorRateBArr.push(getKmlcpycList_list.value[i].erProbeResistanceCorRateB)
            }
            if (sampTimeArr.length > 25) {
                xIetm = parseInt(sampTimeArr.length / 25);
            } else {
                xIetm = 0;
            }
        }
        chart.value = markRaw(echarts.init(chart_container9.value));
        let series = [{
            name: 'ER探头1腐蚀率',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erProbeResistanceCorRateAArr,
        }, {
            name: 'ER探头2腐蚀率',
            type: 'line',
            symbolSize: 2,
            showSymbol: false,
            connectNulls: true,//添加此属性
            data: erProbeResistanceCorRateBArr,
        }]
        let data = ["ER探头1腐蚀率", "ER探头2腐蚀率"]
        for (let i = 0; i < table_data_list_new.value.length; i++) {
            if (table_data_list_new.value[i].off == false) {
                data.splice(data.indexOf(table_data_list_new.value[i].label), 1);
                series = series.filter(item => item.name !== table_data_list_new.value[i].label);
            }

        }

        let option = {
            title: {
                text: getKmlcpycList_list.value.length > 0 ? '时间区间：' + getKmlcpycList_list.value[0].sampTime + '~' + getKmlcpycList_list.value[getKmlcpycList_list.value.length - 1].sampTime : '',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                top: '6%',
                data: data,
                textStyle: {
                    fontSize: 12,
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: '保存为图片',
                        type: 'png',
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'none'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'none'
                }
            ],

            grid: {
                left: '15%',
                // right: '10%',
                bottom: '25%',
                containLabel: true,
            },

            yAxis: {
                type: 'value',
                // name: '电压/V',
                boundaryGap: [0, 0.5],
                axisLabel: {
                    textStyle: {
                        fontWeight: 600
                    }

                },
            },
            xAxis: {
                name: '采样时间',
                data: sampTimeArr,
                axisLabel: {
                    interval: xIetm,
                    rotate: 45,
                    textStyle: {
                        fontWeight: 600
                    }
                },
            },
            series: series
        };
        chart.value.setOption(option);
    })
}
//#endregion

//#region 分页列表
const list_data = ref([])
const find_data = reactive({
    pageNo: 1,
    pageSize: 14,
    checkPoints: [],
    customerIds: [],
    pipeLineIds: [],
    startTime: "",
    endTime: "",
    rules: '',

})
const total = ref(0)

// 分页器一夜显示多少数据页面
const size_change_btn = () => {
    find_data.pageNo = 1
    list_api()
}

// 分页器跳转页面
const current_change_btn = () => {
    list_api()
}

const list_api = () => {

    find_data.checkPoints = getCheckPointListByLineId_value.value,
        find_data.customerIds = checkPointIds.value,
        find_data.pipeLineIds = getPipeLineListByCusId_value.value,

        find_data.startTime = details_time.value[0],
        find_data.endTime = details_time.value[1],
        getKmlptycAlarmListByPage(find_data).then(res => {

            if (res.resultStatus.resultCode == '0000') {
                list_data.value = res.value.list
                total.value = res.value.total
            } else {
                return ElMessage({
                    message: res.resultStatus.resultMessage,
                    type: 'warning',
                })
            }

        })
}
//#endregion



//#region 表格选择
const table_list = ref([])
const selection_change_btn = (e) => {
    table_list.value = e
    console.log(e)
}
//#endregion

//#region 删除
const del_btn = () => {
    if (table_list.value.length != 1) {
        return ElMessage({
            message: '请选择一条数据！',
            type: 'warning',
        })
    }

    ElMessageBox.confirm(
        '是否确认删除该数据?',
        {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
            distinguishCancelAndClose: 'true',
        }
    )
        .then(() => {
            let ps = []
            for (let i = 0; i < table_list.value.length; i++) {
                ps.push(table_list.value[i].id)
            }
            deleteKmlptyc(ps).then(res => {
                if (res.resultStatus.resultCode == '0000') {
                    list_api()
                    return ElMessage({
                        message: res.resultStatus.resultMessage,
                        type: 'success',
                    })
                } else {
                    return ElMessage({
                        message: res.resultStatus.resultMessage,
                        type: 'warning',
                    })
                }
            })
        })
        .catch((e) => {
            if (e == 'cancel') {
                ElMessage({
                    type: 'warning',
                    message: '取消删除成功',
                })
            }

        })

}
//#endregion

//#region 导出
const out_btn = () => {



    let ps = {
        checkPoints: getCheckPointListByLineId_value.value,
        customerIds: checkPointIds.value,
        pipeLineIds: getPipeLineListByCusId_value.value,
        startTime: details_time.value[0],
        endTime: details_time.value[1],

    }

    importErrorKmlptyc(ps).then(res => {
        downFiles(res, '恒电位仪告警')



    })


}
//#endregion

</script>

<style scoped lang='scss'>
::v-deep(.el-tabs__item) {
    background-color: #DBE0E5;
    color: black;
    width: 100px;
    text-align: center;

}

::v-deep(.is-active) {
    background-color: #3D5674;
    color: #fff;

}

.del_btn_Css {
    margin-top: 10px;
}

.list_data_Css {
    width: 100%
}

.current_change_btn_css {
    margin-top: 20px
}




.map_input {
    width: 100%;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;

}

.div_bg:hover {
    background-color: darkgray;
}
</style>
<style>
.col-items::-webkit-scrollbar {
    width: 5px !important;
}

.col-items>label {
    margin-left: 0px !important;
    margin-top: 5px;
    width: 100%;
}
</style>
